package main

import (
	"fmt"
)

/**
执行用时：68 ms, 在所有 Go 提交中击败了67.89%的用户
内存消耗：9.5 MB, 在所有 Go 提交中击败了13.01%的用户
 */

const N = 20003

type MyHashSet struct {
	h [][]int
}

func Constructor() MyHashSet {

	return MyHashSet{h: make([][]int, N)}
}

func find(bin []int, key int) int {
	for i := 0; i < len(bin); i++ {
		if bin[i] == key {
			return i
		}
	}
	return -1
}

func (this *MyHashSet) Add(key int) {

	t := key % N
	k := find(this.h[t], key)
	if k == -1 { this.h[t] = append(this.h[t], key) }
}

func (this *MyHashSet) Remove(key int) {
	t := key % N
	k := find(this.h[t], key)
	if k != -1 { this.h[t] = append(this.h[t][:k], this.h[t][k + 1:]...) }
}

func (this *MyHashSet) Contains(key int) bool {
	t := key % N
	k := find(this.h[t], key)
	return k != -1
}

func main() {

	obj := Constructor()
	obj.Add(1)
	obj.Add(2)
	fmt.Println(obj.Contains(1))  // true
	fmt.Println(obj.Contains(3))  // false
	obj.Remove(2)
	fmt.Println(obj.Contains(2))  // false
}
